package com.lzh.fastjson.deserializer;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

import java.lang.reflect.Type;
import java.time.YearMonth;

/**
 * @author zhehen.lu
 * @date 2025/8/10 14:41
 */
public class FastjsonYearMonthDeserializer implements ObjectDeserializer {
    private static final String PATTERN = "yyyy-MM";

    public FastjsonYearMonthDeserializer() {
    }

    @Override
    public YearMonth deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        String stringVal = parser.getLexer().stringVal();
        return stringVal == null ? null : YearMonth.parse(stringVal);
    }

    @Override
    public int getFastMatchToken() {
        return 0;
    }
}
